package com.demo.framework.log;

import java.io.File;
import java.io.IOException;
import org.apache.log4j.DailyRollingFileAppender;
import org.apache.log4j.PatternLayout;

import com.demo.framework.constant.ConstantDef.AppLogConstDef;

import android.os.Environment;


public class LoggingUtil {

    public static void initLoggers() {
        org.apache.log4j.Logger root = org.apache.log4j.Logger.getRootLogger();
        PatternLayout layout = new PatternLayout("%d{yyyy-MM-dd HH:mm:ss,SSS} [%-5p][%c@%t] - %m%n");
        root.addAppender(new org.apache.log4j.ConsoleAppender(layout));
        root.setLevel(AppLogConstDef.ROOT_LOGGER_LEVEL);
        String file = Environment.getExternalStorageState() + File.separator + "crm/jitmarketing.log";
        try {
            root.addAppender(new DailyRollingFileAppender(layout, file, ".yyyy-MM-dd"));
            android.util.Log.i("LoggingUtil", "创建日志文件  " + file);
        }
        catch(IOException e) {
            android.util.Log.e("LoggingUtil", "无法创建日志文件 jitmarketing.log", e);
        }
    }
}
